﻿<UserControl x:Class="CredentialsManager.Views.UpdatePasswordQuestionView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             Height="250" Width="300">
    <UserControl.Resources>
        <Style x:Key="NoQuestionStyle" TargetType="{x:Type FrameworkElement}">
            <Setter Property="Visibility" Value="Visible" />
            <Style.Triggers>
                <DataTrigger Binding="{Binding SecurityQuestion}" Value="{x:Null}">
                    <Setter Property="Visibility" Value="Collapsed" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>
    <StackPanel>
        <Label>User Name:</Label>
        <TextBox IsEnabled="{Binding IsUserNameEditable}" Text="{Binding UserName, UpdateSourceTrigger=PropertyChanged}" TabIndex="0" />
        <TextBlock Text="{Binding SecurityQuestion}" TextWrapping="WrapWithOverflow" Margin="0, 10, 0, 10" 
                   Style="{StaticResource NoQuestionStyle}" />
        <TextBox Text="{Binding SecurityAnswer, UpdateSourceTrigger=PropertyChanged}"
                 Style="{StaticResource NoQuestionStyle}" />
        <Label>New security Question:</Label>        
        <TextBox Text="{Binding NewSecurityQuestion, UpdateSourceTrigger=PropertyChanged}" TabIndex="4" />
        <Label>New security Answer:</Label>
        <TextBox Text="{Binding NewSecurityAnswer, UpdateSourceTrigger=PropertyChanged}" TabIndex="5" />
        <WrapPanel>
            <Button 
                Content="Update" Command="{Binding UpdateCommand}" 
                IsEnabled="{Binding IsValid}" IsDefault="True" 
                Margin="5" Padding="5"
                />
            <Button Command="{Binding CloseCommand}" IsCancel="True" Content="Close" Margin="5" Padding="5" />
        </WrapPanel>
    </StackPanel>
</UserControl>
